//
//  FKFastShareModel.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/19.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKFastShareModel.h"

@implementation FKFastShareModel

- (void)mj_keyValuesDidFinishConvertingToObject
{
    NSString *addTime = [_add_time fk_timeWithFormat:@"yyyy-MM-dd HH:mm"];
    _publishTime = fkFORMAT(@"发布时间: %@", addTime);
    
//    _infoStr = [_info fk_htmlToString];
    
    CGFloat avatarH = fk_adjustW(35);
    _cellH += (fk_adjustW(10) + avatarH);
    
    if (_info.length > 0) {
        CGFloat infoH = [_info boundingRectWithSize:CGSizeMake(fkScreenW - 24, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : fk_adjustFont(16)} context:nil].size.height;
        
//        _infoFrame = CGRectMake(12, fk_adjustW(57), fkScreenW - 24, infoH);
        _cellH += (fk_adjustW(12) + infoH);
    }
    
    if ([_market_type isEqualToString:@"1"]) { // 1 图片九宫格
        CGFloat beginImageY = _cellH + fk_adjustW(9);
        NSMutableArray *imageFrames = [NSMutableArray array];
        CGFloat imageWH = fk_adjustW(90);
        CGFloat beginX = 12;
        CGFloat margin = fk_adjustW(5);
        for (NSInteger index = 0; index < _imgs.count; index++) {
            NSInteger row = index / 3;
            NSInteger column = index % 3;
            CGFloat imageX = beginX + column * (imageWH + margin);
            CGFloat imageY = beginImageY + row * (imageWH + margin);
            CGRect imageFrame = CGRectMake(imageX, imageY, imageWH, imageWH);
            [imageFrames addObject:@(imageFrame)];
        }
        NSInteger rows = _imgs.count % 3 == 0 ? _imgs.count / 3 : _imgs.count / 3 + 1;
        _cellH += (fk_adjustW(9) + rows * (margin + imageWH) - margin);
        _imageFrames = imageFrames;
    } else if ([_market_type isEqualToString:@"2"]) { // 链接
        _cellH += (fk_adjustW(10) + fk_adjustW(80));
    }
    
    _cellH += fk_adjustW(65);
}

@end
